﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace csharpcore7_ch14_ConcurrencyAndAsynchrony
{
    class chapt14_2_Thread
    {
        static void _Main()
        {
            Thread t = new Thread(WriteY);//开一个新线程
            t.Start();  //启动线程
            t.Join();   //等线程结束
            Console.WriteLine("线程完成");

            //Simultaneously,do something on the main thread,同时，在主线程上做一些事情
            for (int i = 0; i < 100; i++) Console.Write("x");
            Console.WriteLine("1111"+Thread.CurrentThread.Name);
        }

        static void WriteY()
        {
            for (int i = 0; i < 1000; i++) Console.Write("y");
            Console.WriteLine("2222"+Thread.CurrentThread.Name);
        }
    }

}
